package neu.soft.controller;


import neu.soft.entity.DistributionTaskOrder;
import neu.soft.entity.NormalOrder;
import neu.soft.feignclient.DispatchFeignClient;
import neu.soft.service.impl.TaskOrderServiceImpl;
import neu.soft.vo.PageBean;
import neu.soft.vo.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ruixi
 * @since 2023-6-25
 */

@RestController
@RequestMapping("/taskOrder")
@CrossOrigin
public class TaskOrderController {

    @Autowired
    private TaskOrderServiceImpl taskOrderService;

    @Autowired
    private DispatchFeignClient dispatchFeignClient;


    /*
    *
    * 根据任务单id查询任务单
    *
    * */
    @RequestMapping("/findById")
    public ResultBean<DistributionTaskOrder> findById(String id) {
        return taskOrderService.findById(id);
    }

    /*
    *
    * 根据”要求完成日期“、”任务类型“、”任务状态“查询任务单
    *
    * */
    @RequestMapping("/findByConditions")
    public ResultBean<PageBean<DistributionTaskOrder>> findByConditions(@RequestBody Map<String ,Object> map) {
        return taskOrderService.findByConditions(map);
    }

    /*
    *
    * 查询所有任务单
    *
    * */
    @RequestMapping("/findAll")
    public ResultBean<PageBean<DistributionTaskOrder>> findAll(@RequestBody Map<String , Object> map) {
        return taskOrderService.findAll(map);
    }

    /*
     *
     * 为配送单分配投递员
     *
     * */
    @RequestMapping("/findPostmanForOrder")
    public ResultBean<List<DistributionTaskOrder>> findPostmanForOrder(String distributionTaskOrders) {
        return taskOrderService.findPostmanForOrder(distributionTaskOrders);
    }

    /*
    *
    * 获取打印配送单的信息
    *
    * */
    @RequestMapping("/getPrintTaskOrder")
    public ResultBean<Map<String, Object>> getPrintTaskOrder(String distributionOrderId, String orderId) {


        return taskOrderService.getPrintTaskOrder(distributionOrderId, orderId);
    }


    /*
    *
    * 回执录入
    *
    * */
    @RequestMapping("/receiptEntry")
    public ResultBean receiptEntry(@RequestBody Map<String ,Object> map) {

        System.out.println(map);
        taskOrderService.receiptEntry(map);
        return null;
    }

    /*
    *
    * 查找商品信息
    *
    * */
    @RequestMapping("findShopping")
    public ResultBean findShopping(String oid) {
        return dispatchFeignClient.findShopping(oid);
    }

}
